﻿using System;
using System.Collections.Generic;
using YJKPatternSign.StairsRoomPlanSign.ModelLayer;

namespace YJKPatternSign.StairsRoomPlanSign.ControlLayer
{
	public class StairsKindDetector
	{
		private StairsKindDetector()
		{
			this.m_lstUseDetectors = new List<BaseStairsKindDetector>
			{
				new ScissorStairDetctor(),
				new DoubleStairsDetctor()
			};
		}

		public static StairsKindDetector GetDetector()
		{
			if (StairsKindDetector.m_singleTag == null)
			{
				StairsKindDetector.m_singleTag = new StairsKindDetector();
			}
			return StairsKindDetector.m_singleTag;
		}

		public bool TryDetectStairsKind(SignUseStairsPacker inputStairPackers, out StairsKindEnum nowEnum)
		{
			nowEnum = StairsKindEnum.Error;
			if (inputStairPackers == null || inputStairPackers.LstAllSameLevelStairsPacker.Count == 0)
			{
				return false;
			}
			foreach (BaseStairsKindDetector baseStairsKindDetector in this.m_lstUseDetectors)
			{
				if (baseStairsKindDetector.DetectThisStairs(inputStairPackers))
				{
					nowEnum = baseStairsKindDetector.ThisStairsKind;
					return true;
				}
			}
			return false;
		}

		private List<BaseStairsKindDetector> m_lstUseDetectors = new List<BaseStairsKindDetector>();

		private static StairsKindDetector m_singleTag;
	}
}
